package com.api.core.service.impl;

import com.api.common.enums.DataSourceType;
import com.api.core.domain.query.ResourceQuery;
import com.api.core.domain.vo.IpcVo;
import com.api.core.mapper.ClusterRealtimeMapper;
import com.api.core.service.IClusterRealtimeService;
import com.api.core.service.IiPcService;
import com.api.framework.datasource.DynamicDataSourceContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClusterRealtimeServiceImpl implements IClusterRealtimeService {
    @Autowired
    private ClusterRealtimeMapper clusterRealtimeMapper;

    @Autowired
    private IiPcService ipcService;

    @Override
//    @DataSource(value = DataSourceType.SLAVE)
    public ResourceQuery resourceLatest(String tableName) {
        DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.SLAVE.name());
        ResourceQuery query = clusterRealtimeMapper.resourceLatest(tableName);
        DynamicDataSourceContextHolder.clearDataSourceType();
        return query;
    }

    @Override
    public List<ResourceQuery> resourceList(IpcVo vo) {
        DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.SLAVE.name());
        List<ResourceQuery> queryList = clusterRealtimeMapper.resourceList(vo);
        DynamicDataSourceContextHolder.clearDataSourceType();
        return queryList;
    }


//    @Override
//    public List<Double> getTimestampGenerateList(TreeVo vo){
//        DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.SLAVE.name());
//        List<Double> dataList = clusterRealtimeMapper.getTimestampGenerateList(vo.getEvaluationTabName("002","001") ,vo);
//        DynamicDataSourceContextHolder.clearDataSourceType();
//        return dataList;
//    }

//    @Override
//    public List<EvaluationScroeQuery> evaluationScroe(EvalScoreVo vo) {
//        DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.SLAVE.name());
//        List<EvaluationScroeQuery> dataList = clusterRealtimeMapper.evaluationScroe(vo);
//        DynamicDataSourceContextHolder.clearDataSourceType();
//        return dataList;
//    }


//    @Override
//    public List<EvaluationSeriesQuery> evaluationSeries(EvalScoreVo vo) {
//        DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.SLAVE.name());
//        List<EvaluationSeriesQuery> dataList = clusterRealtimeMapper.evaluationSeries(vo);
//        DynamicDataSourceContextHolder.clearDataSourceType();
//        return dataList;
//    }

//    @Override
//    public void getSerializationList(String tableName){
//
//    }

//    @Override
//    public void getEvaluationList(String tableName) {
//
//    }
}
